package com.lensong.plugin.sentinel.controller;

import com.lensong.plugin.sentinel.service.SentinelAnnotationService;
import com.lensong.plugin.sentinel.service.SentinelSphUService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Copyright （c）. All rights reserved.
 *
 * @author len.song
 * @date 2021/09/20
 */
@Controller
@RequestMapping("/sentinel")
public class SentinelDemoController {
    @Resource
    private SentinelAnnotationService sentinelAnnotationService;
    @Resource
    private SentinelSphUService sentinelSphUService;

    @ResponseBody
    @GetMapping("/annotationBlock01")
    public String annotationBlock01() {
        return sentinelAnnotationService.annotationBlock01();
    }

    @ResponseBody
    @GetMapping("/annotationBlock02")
    public String annotation() {
        return sentinelAnnotationService.annotationBlock02();
    }

    @ResponseBody
    @GetMapping("/annotationFallbackValue01")
    public String annotationFallbackValue01() {
        return sentinelAnnotationService.annotationFallbackValue01();
    }

    @ResponseBody
    @GetMapping("/annotationFallbackValue02")
    public String annotationFallbackValue02() {
        return sentinelAnnotationService.annotationFallbackValue02();
    }


    @ResponseBody
    @GetMapping("/sphUTest")
    public String sphU() {
        sentinelSphUService.entryBySphU();
        return "success";
    }
}
